package com.xjgc.eip.panel.controller;


import java.util.List;

import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xjgc.common.entity.ReturnResult;
import com.xjgc.common.utils.TransNoUitl;
import com.xjgc.eip.panel.entity.ZxjEipBg;
import com.xjgc.eip.panel.service.ZxjEipBgService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wxy
 * @since 2019-11-08
 */
@RestController
@RequestMapping("/zxjEipBg")
public class ZxjEipBgController {
    @Autowired
    private ZxjEipBgService zxjEipBgService;
    @RequestMapping("workOrder")
    public ReturnResult workOrder(){
        ZxjEipBg zxjEipBg = new ZxjEipBg();
        zxjEipBg.setIoflag("1");
        QueryWrapper<ZxjEipBg> queryWrapper = new QueryWrapper();
        queryWrapper.setEntity(zxjEipBg);
        List<ZxjEipBg> list = zxjEipBgService.list(queryWrapper);
        ReturnResult returnResult = new ReturnResult();
        returnResult.setData(list);
        String orisys="0";
        String transno="";
        String operatetype="add";
        for (ZxjEipBg zes:list) {

            //header数据
            if ("0".equals(zes.getStatus())){
                transno= TransNoUitl.genTransNo();
            }else if ("1".equals(zes.getStatus())){
                transno= TransNoUitl.genTransNo();
                operatetype="update";
            }
            //body数据  就是zex
            //TODO   调用接口推送数据
            //TODO   根据返回状态  status 修改推送结果
        }
        return returnResult;
    }
    @GetMapping(value="/list")
    public Result<IPage<ZxjEipBg>> queryPgList(ZxjEipBg zxjEipBg,
                                                 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                                 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
        Result<IPage<ZxjEipBg>> result = new Result<IPage<ZxjEipBg>>();
        Page<ZxjEipBg> page = new Page<ZxjEipBg>(pageNo,pageSize);
        QueryWrapper<ZxjEipBg> queryWrapper = new QueryWrapper<ZxjEipBg>(zxjEipBg);
        IPage<ZxjEipBg> pageList = zxjEipBgService.page(page,queryWrapper);
        result.setSuccess(true);
        result.setResult(pageList);
        return result;
    }
}

